package demo;

import utils.DBUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author tongchen
 * @create 2022-12-27 14:09
 */
public class Delete {
    //定义变量
    private static Connection connection;
    private static PreparedStatement statement;
    private static ResultSet resultSet;
    //获取连接
    public static void main(String[] args) {
        try {
           connection= DBUtils.getConnection();
            //定义sql
            String sql="delete from student where id =?";
            //设置执行器
          statement=  connection.prepareStatement(sql);
          //解决问号
            statement.setInt(1,12);
            //执行sql
            int i = statement.executeUpdate();
            if(i>0){
                System.out.println("执行成功  ");
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
